package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.SensitiveDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.SensitiveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/v1/sensitive")
@Api(value = "自媒体-敏感词管理", tags = "自媒体敏感词")
public class SensitiveController {

    @Autowired
    SensitiveService sensitiveService;

    /**
     * 新增 敏感词
     * @param dto
     * @return
     */
    @PostMapping("save")
    @ApiOperation("敏感词新增功能")
    public ResponseResult save(@RequestBody WmSensitive dto){
        return  sensitiveService.insert(dto);
    }

    /**
     * 修改敏感词
     * @param dto
     * @return
     */
    @PostMapping("update")
    public ResponseResult update(@RequestBody WmSensitive dto){
        return sensitiveService.update(dto);
    }


    /**
     * 删除 敏感词
     * @param id
     * @return
     */
    @DeleteMapping("del/{id}")
    public ResponseResult del(@PathVariable("id") Integer id){
        return sensitiveService.del(id);
    }


    @PostMapping("list")
    public ResponseResult list(@RequestBody SensitiveDto dto){
        return sensitiveService.list(dto);
    }

}
